package com.yulebaby.callsenter.adapter.selectadpter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.yulebaby.callsenter.R;

/**
 * Author: Zhangbo
 * Time: 2017/1/17
 */
public class DateRightAdapter extends BaseAdapter {

    private String[] listMore;
    private Context mContext;

    private ViewHolder viewHolder;

    public DateRightAdapter(Context context, String[] list) {
        this.listMore = list;
        this.mContext = context;
    }


    public void setCheckItem() {
        notifyDataSetChanged();
    }


    @Override
    public int getCount() {
        return listMore.length;
    }

    @Override
    public Object getItem(int position) {
        return listMore[position];
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        if (convertView == null) {
            convertView = View.inflate(mContext, R.layout.item_default_drop_down, null);
            viewHolder = new ViewHolder(convertView);
            convertView.setTag(viewHolder);
        } else {
            viewHolder = (ViewHolder) convertView.getTag();
        }
        fillValue(position, viewHolder);
        return convertView;
    }

    private void fillValue(int position, ViewHolder viewHolder) {
        viewHolder.textView.setText(listMore[position]);
        viewHolder.textView.setTextColor(mContext.getResources().getColor(R.color.yulebaby_drop_down_unselected));
        viewHolder.textView.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null);
    }

    private static class ViewHolder {
        private TextView textView;

        ViewHolder(View view) {
            textView = (TextView) view.findViewById(R.id.tv_select);
        }
    }
}
